Several application development projects use object technology to build application software. An object is a programming data structure which includes data values and procedures that can manipulate the data values. For example, in the Java® programming language, a class is a template describing the data values and procedures that are grouped together to represent something, and an object is a variable constructed according to the template of the class. In other words, an object is an instance of a class, or template. Once an object is created from the class, or template, the object resides in the memory of the application while the object is in use by the application. The object is then removed from memory once the object is no longer in use by the application.
An object can be made to outlive the lifetime of the application which created the object through the process of serialization and deserialization. Serialization is the process of saving the current state of an object to a sequence of bytes, such as a stream. Deserialization is the process of later constructing an equivalent object from the sequence of bytes. The sequence of bytes serves as a container for the object, where the sequence of bytes includes a partial representation of the object's data values and procedures. The container may be transient in order to allow the object to be transported from one application to another, possibly over a network. As an alternative, the container may be persistent so that the object may be stored on a storage medium, so that the object is accessible even after the application which created the object is terminated. In both cases, the information stored in the container can later be used to construct an equivalent object containing the same data values and procedures as the original object.
In the scenario where an object includes a reference to another object, this referenced object (and the referenced object's associated data) is also serialized and stored as part of the container. This is done in order to avoid the reconstructed object containing null object references when it is reconstructed from the container. Furthermore, in the scenario when the object includes a reference to another object, when the object is deserialized, the object references are also reconstructed from the stream that the object was deserialized from. This is done because only the stream contains the current state of the referenced objects.